package com.qubuyer.core.http

import okhttp3.Interceptor
import okhttp3.Response

/**
 * Author: linwg
 * Time: 2021/2/4 0004
 * Description:
 */
class TokenInterceptor : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        val needAuth = request.header("NeedAuth") == null
        return if (needAuth) {
            chain.proceed(request.newBuilder().addHeader("token", OkHttpUtil.token).build())
        } else {
            chain.proceed(request)
        }
    }
}